//
//  DiseaseArrayViewController.m
//  MyYiJianKangApp
//
//  Created by 张国文 on 16/5/3.
//  Copyright © 2016年 hangzhouyijiyin. All rights reserved.
//

#import "DiseaseArrayViewController.h"
#import "DanXiangArrayModel.h"
#import "DiseaseDanXiangTableViewCell.h"
#import "DanXiangBingDetailViewController.h"

@interface DiseaseArrayViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) UITableView *diseaseArrayTableview; // 疾病TV

@end

@implementation DiseaseArrayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    // navi的修改
    [self changeNavigation];
    // 添加视图
    [self addMySubview];
}

// navi的修改
- (void)changeNavigation
{
    [self.navigationController.navigationBar setTranslucent:NO];
    
    // 左边
    UIImageView *leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    leftImageView.image = [UIImage imageNamed:@"houtui"];
    UITapGestureRecognizer *leftTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(lastPage:)];
    [leftImageView addGestureRecognizer:leftTapGes];
    UIBarButtonItem *leftFirstItem = [[UIBarButtonItem alloc] initWithCustomView:leftImageView];
    
    UILabel *productPackageNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 30)];
    productPackageNameLabel.text = self.productTitle;
    productPackageNameLabel.textColor = [UIColor whiteColor];
    productPackageNameLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k18Big];
    productPackageNameLabel.textAlignment = NSTextAlignmentLeft;
    UIBarButtonItem *leftSecondItem = [[UIBarButtonItem alloc] initWithCustomView:productPackageNameLabel];
    self.navigationItem.leftBarButtonItems = @[leftFirstItem, leftSecondItem];
    
  //  NSLog(@"self.diseaseArray = %@", self.diseaseArray);
    
    
}

#pragma mark - 返回
- (void)lastPage:(UITapGestureRecognizer *)tapGes
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - 构建视图
- (void)addMySubview
{
    self.diseaseArrayTableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - 64)];
    self.diseaseArrayTableview.dataSource = self;
    self.diseaseArrayTableview.delegate = self;
    self.diseaseArrayTableview.showsVerticalScrollIndicator = NO;
    self.diseaseArrayTableview.bounces = NO;
    [self.view addSubview:_diseaseArrayTableview];
}


#pragma mark - tableView代理
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.diseaseArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"diseaseDanXiang";
    DiseaseDanXiangTableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[DiseaseDanXiangTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.model = self.diseaseArray[indexPath.row];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 107 * kAdjustParamater;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    DanXiangBingDetailViewController *danXiangBingDetailVC = [[DanXiangBingDetailViewController alloc] init];
    if (self.diseaseArray.count > indexPath.row) {
        DanXiangArrayModel *model = self.diseaseArray[indexPath.row];
       danXiangBingDetailVC.danXiangID = [NSString stringWithFormat:@"%@", model.danXiangID];
    }
    [self.navigationController pushViewController:danXiangBingDetailVC animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
